program define mcprobit_lf
args lnf xb a0 a1
tempvar normalprob

#delimit ;
quietly generate double `normalprob' = cond($ML_y1==1, 
	normal(`a0')+(1-normal(`a0')-normal(`a1'))*normal(`xb'), 
	1-normal(`a0')-(1-normal(`a0')-normal(`a1'))*normal(`xb') ) 
	if $ML_samp==1;
#delimit cr

if normal(`a0')+normal(`a1') < 1 {
	quietly replace `lnf' = ln(`normalprob')
}
else {
	qui replace `lnf'=.
}

end
